<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>广告弹窗</title>
    <style>
        .moTai {
            width: 300px;
            height: 300px;
            text-align: center;
            line-height: 300px;
            position: fixed;
            left: 50%;
            top: 50%;
            margin-top: -150px;
            margin-left: -150px;
            background-color: rgba(0, 255, 255, 0.7);
        }

        .del {
            width: 30px;
            height: 30px;
            background-color: red;
            text-align: center;
            line-height: 30px;
            position: absolute;
            top: 0;
            right: 0;
        }

        .show {
            display: none;
        }
    </style>
</head>

<body>
    <button onclick="add()">点击广告哟~</button>
    <div class="moTai show">
        <div class="del" onclick="del()">X</div>
        <span>广告广告广告</span>
    </div>
    <script>
        function add() {
            let moTai = document.querySelector('.moTai');
            moTai.classList.remove('show');
        }
        function del() {
            let moTai = document.querySelector('.moTai');
            moTai.classList.add('show');
        }
    </script>
</body>
